﻿#region Using Statements
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework;
using DotNetEngine.Core;
using DotNetEngine.Graphics;
using DotNetEngine.Utils; 
#endregion

namespace DotNetEngine.Graphics
{
    public class DrawableImage : DrawableElement
    {
        Texture2D image;
        float scale = BaseGame.Width/1280f;

        #region Properties
        #endregion

        #region Initialize Methods
        public DrawableImage(string imagePath, Vector2 position, int layer)
            : this(imagePath, position, Color.White, layer) { }

        public DrawableImage(string imagePath, Vector2 position, Color color, int layer)
        {
            if(string.IsNullOrEmpty(imagePath))
            {
                Log.Instance.Write("Failed: Loading " + imagePath);
                return;
            }

            this.image = BaseGame.BaseContent.Load<Texture2D>(imagePath);
            this.Position = position;
            this.Color = color;
            this.Layer = layer;
        }

        #endregion

        #region Public Methods
        public override void Draw()
        {
            //BaseGame.RenderTarget.Draw(image, BaseGame.Device.Viewport.TitleSafeArea, Color);
            //Realmente
            //BaseGame.RenderTarget.Draw(image, Position, Color);
            //Solucion temporal sirve para escalar el  fondo pero para objetos mas pequeños...
            BaseGame.RenderTarget.Draw(image, Position, new Rectangle(0, 0, image.Width, image.Height), Color, 0, Position, scale, SpriteEffects.None, 1);
        } 

        #endregion

        #region Private Methods
        #endregion
    }
}
